﻿/*----------------------------------------------------------------
//  <copyright file="QQOptions.cs" company="MicroCloud@151504200868">
//      Copyright © 2020-2024 MicroCloud Corporation, All rights reserved.
//  </copyright>
//  <site>https://gitee.com/chenmm123/microclouds</site>
//  <last-editor>cmm</last-editor>
//  <last-date>2023-12-06 08:34</last-date>
//----------------------------------------------------------------*/

namespace MicroCloud.Authentication.OAuth2.QQ
{
    #region "QQ身份认证选项"
    /// <summary>
    /// QQ身份认证选项
    /// </summary>
    public class QQOptions : OAuthOptions
    {
        #region "属性"
        #region "获取 OpenId请求的终结点"
        /// <summary>
        /// 获取 OpenId请求的终结点
        /// </summary>
        public string OpenIdEndpoint { get; }
        #endregion
        #region "获取或设置 QQ互联 AppId"
        /// <summary>
        /// 获取或设置 QQ互联 AppId 
        /// https://connect.qq.com
        /// </summary>
        public string AppId
        {
            get { return ClientId; }
            set { ClientId = value; }
        }
        #endregion
        #region "获取或设置 QQ互联 AppKey"
        /// <summary>
        /// 获取或设置 QQ互联 AppKey
        /// https://connect.qq.com
        /// </summary>
        public string AppKey
        {
            get { return ClientSecret; }
            set { ClientSecret = value; }
        }
        #endregion

        #endregion

        #region "构造函数"
        #region "初始化一个QQ身份认证选项的新实例"
        /// <summary>
        /// 初始化一个QQ身份认证选项 <see cref="QQOptions"/> 的新实例
        /// </summary>
        public QQOptions()
        {

            ClaimsIssuer = QQDefaults.Issuer;
            CallbackPath = new PathString(QQDefaults.CallbackPath);

            AuthorizationEndpoint = QQDefaults.AuthorizationEndpoint;
            TokenEndpoint = QQDefaults.TokenEndpoint;
            UserInformationEndpoint = QQDefaults.UserInformationEndpoint;
            OpenIdEndpoint = QQDefaults.OpenIdEndpoint;

            //StateDataFormat = 
            //Scope 表示用户授权时向用户显示的可进行授权的列表。
            Scope.Add(QQDefaults.get_user_info); //默认只请求对get_user_info进行授权

            ClaimActions.MapJsonKey(ClaimTypes.NameIdentifier, "openid");
            ClaimActions.MapJsonKey(ClaimTypes.Name, "nickname");
            ClaimActions.MapJsonKey(ClaimTypeConstants.HeadImgEx, "figureurl_qq_1");
        }
        #endregion

        #endregion

    }
    #endregion

}
